/*
 * Copyright (c) 2014 Strong Group - 版权所有
 * 
 * This software is the confidential and proprietary information of
 * Strong Group. You shall not disclose such confidential information 
 * and shall use it only in accordance with the terms of the license 
 * agreement you entered into with www.cnstrong.cn.
 */
package com.zuorenke.serialize.support.hessian;

import com.caucho.hessian.io.Hessian2Output;
import com.zuorenke.serialize.ObjectOutput;

import java.io.IOException;
import java.io.OutputStream;

/**
 *
 * 描述:
 *
 * @author  WQB
 * @created 2014-4-7 上午10:09:29
 * @since   v1.0.0
 */
public class Hessian2ObjectOutput implements ObjectOutput {
	private final Hessian2Output mH2o;

	public Hessian2ObjectOutput(OutputStream os) {
		mH2o = new Hessian2Output(os);
		mH2o.setSerializerFactory(Hessian2SerializerFactory.SERIALIZER_FACTORY);
	}

	public void writeBool(boolean v) throws IOException {
		mH2o.writeBoolean(v);
	}

	public void writeByte(byte v) throws IOException {
		mH2o.writeInt(v);
	}

	public void writeShort(short v) throws IOException {
		mH2o.writeInt(v);
	}

	public void writeInt(int v) throws IOException {
		mH2o.writeInt(v);
	}

	public void writeLong(long v) throws IOException {
		mH2o.writeLong(v);
	}

	public void writeFloat(float v) throws IOException {
		mH2o.writeDouble(v);
	}

	public void writeDouble(double v) throws IOException {
		mH2o.writeDouble(v);
	}

	public void writeBytes(byte[] b) throws IOException {
		mH2o.writeBytes(b);
	}

	public void writeBytes(byte[] b, int off, int len) throws IOException {
		mH2o.writeBytes(b, off, len);
	}

	public void writeUTF(String v) throws IOException {
		mH2o.writeString(v);
	}

	public void writeObject(Object obj) throws IOException {
		mH2o.writeObject(obj);
	}

	public void flushBuffer() throws IOException {
		mH2o.flushBuffer();
	}
}